use serde::{Deserialize, Serialize};
use wanmesh_common::net::wireguard;
use serde_with::base64::Base64;
use crate::dto;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EndpointPeerWireguardConfig {
    pub config: WireguardConfig,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all(serialize = "PascalCase", deserialize = "PascalCase"))]
pub struct WireguardConfig {
    pub peer: WireguardPeerConfig,
}

#[serde_with::serde_as]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all(serialize = "PascalCase", deserialize = "PascalCase"))]
pub struct WireguardPeerConfig {
    #[serde(flatten)]
    pub inner: dto::core::endpoint_peer_wireguard_config::WireguardPeerConfig,
    #[serde_as(as = "Base64")]
    pub public_key: [u8; wireguard::key::KEY_LEN],
}
